home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Periodicals / develop / develop Issue 19 / develop 19 code / SimpliFace_V2 / Sources / ObjModelTokens.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-15  |  5.7 KB  |  229 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        ObjModelTokens.h
  3.  
  4.     Contains:    Token classes interface
  5.  
  6.  
  7.     Developed by:
  8.  
  9.     Paul G Smith (commstalk hq & Full Moon Software, Inc)
  10.  
  11.     you can leave messages at (UK): 0727 844232; (US): 408 253 7199
  12.     BUT I prefer to be contacted by e-mail
  13.     AppleLink:     COMMSTALK.HQ
  14.     Internet:     COMMSTALK.HQ@applelink.apple.com
  15.  
  16.     "SimpliFace2" Sample code to accompany develop article
  17.     on techniques for controlling script inheritance.
  18.     
  19.     
  20.  
  21.  
  22.     Apple Event Object Model tokens for SimpliFace2
  23.  
  24. */
  25.  
  26. #ifndef __AEOMTOKENS__
  27. #define __AEOMTOKENS__
  28.  
  29. #ifndef __SimpliFace2__
  30. #include "SimpliFace2.h"
  31. #endif
  32.  
  33. #ifndef __SimpliFace2COMMON__
  34. #include "SimpliFace2Common.h"
  35. #endif
  36.  
  37. #ifndef __APPLEEVENTS__
  38. #include "AppleEvents.h"
  39. #endif
  40.  
  41. #ifndef __PASCALSTRING__
  42. #include <PascalString.h>
  43. #endif
  44.  
  45. #ifndef __SCRIPTOBJECTS__
  46. #include "ScriptableObjects.h"
  47. #endif
  48.  
  49.  
  50.  
  51. // object model classes
  52.  
  53. class TObjModelToken
  54. {
  55. public:        
  56.                         TObjModelToken(void);                    // constructor
  57.                         TObjModelToken(DescType theTokenClass,
  58.                                         TScriptableObject* theObj);    // initialise
  59.                         TObjModelToken(const TObjModelToken&);    // initialise
  60.     virtual                ~TObjModelToken(void);                    // virtual destructor
  61.     TObjModelToken&    operator=(const TObjModelToken&);
  62.     
  63.     virtual TObjModelToken* MakeClone(void);
  64.     
  65.     // support for object accessors
  66.     
  67.     virtual  TObjModelToken* MakeNewToken(DescType theTokenClass,
  68.                                         TScriptableObject* theObj);
  69.                                         
  70.     virtual  OSErr ResolveElement(DescType desiredClass,
  71.                                         DescType keyForm,
  72.                                         AEDesc *keyData,
  73.                                         TObjModelToken **theResultToken);
  74.                                         
  75.     virtual  OSErr ResolveProperty(DescType desiredClass,
  76.                                         DescType keyForm,
  77.                                         AEDesc *keyData,
  78.                                         TObjModelToken **theResultToken);
  79.                                         
  80.     
  81.     virtual  OSErr DispatchAppleEvent(AppleEvent *theEvent, 
  82.                                             AppleEvent *theReply, 
  83.                                             AEEventClass theEvtClass,
  84.                                             AEEventID theEvtID);
  85.  
  86.              OSErr CallDispatchAppleEvent(AppleEvent *theEvent, 
  87.                                             AppleEvent *theReply, 
  88.                                             AEEventClass theEvtClass,
  89.                                             AEEventID theEvtID);
  90.     
  91.     inline     DescType            GetTokenClass(void)  { return fTokenClass; } ;
  92.     
  93.     inline     TScriptableObject*    GetTokenObj(void)  { return fTheObject; } ;
  94.     
  95. protected:
  96.     DescType             fTokenClass;    // cLine, cWord, cText, cChar, etc
  97.     Boolean                fIsProperty;
  98.     DescType            fPropertyID;
  99.     TScriptableObject*    fTheObject;
  100.     
  101.     // hooks into Apple Event handling, only override for special-purposes;
  102.     // return noErr if Apple Event was handled within the hook function, or 
  103.     // errAEEventNotHandled if it was not handled within the hook function
  104.     
  105.     virtual  OSErr AECountElems        (AppleEvent *theEvent, 
  106.                                             AppleEvent *theReply);
  107.     
  108.     virtual  OSErr AECreateElem        (AppleEvent *theEvent, 
  109.                                             AppleEvent *theReply);
  110.     
  111.     virtual  OSErr AEDeleteElem        (AppleEvent *theEvent, 
  112.                                             AppleEvent *theReply);
  113.     
  114.     virtual  OSErr AECloseObject       (AppleEvent *theEvent, 
  115.                                             AppleEvent *theReply);
  116.     
  117.     virtual  OSErr AEGetObjectData   (AppleEvent *theEvent, 
  118.                                             AppleEvent *theReply);
  119.     
  120.     virtual  OSErr AEOpenObject      (AppleEvent *theEvent, 
  121.                                             AppleEvent *theReply);
  122.     
  123.     virtual  OSErr AESetObjectData   (AppleEvent *theEvent, 
  124.                                             AppleEvent *theReply);
  125.     
  126.     
  127. };
  128.  
  129. // -------------------------------------------------------
  130.  
  131.  
  132. enum {
  133.     typeObjModelToken    = 'OBJX'    // special descriptor type for our tokens
  134. };
  135.  
  136.  
  137. typedef TObjModelToken* objModelTokenPtr;
  138.  
  139.  
  140.  
  141.  
  142.  
  143. // -------------------------------------------------------
  144.  
  145. objModelTokenPtr ObjModelTokenFromDesc(AEDesc *theDesc);
  146.  
  147. OSErr DescFromObjModelToken(const objModelTokenPtr theToken, AEDesc *theDesc);
  148.  
  149.  
  150. OSErr SFinitAEobjects(void);
  151. // set up SF object model handlers
  152.  
  153. OSErr SFendAEobjects(void);
  154. // detach SF object model handlers & shut down
  155.  
  156.  
  157.  
  158.  
  159. // object accessors 
  160.  
  161. pascal OSErr PropertyFromNullAccessor   (DescType desiredClass,
  162.                                                 AEDesc *containerToken,
  163.                                                 DescType containerClass,
  164.                                                 DescType keyForm,
  165.                                                 AEDesc *keyData,
  166.                                                 AEDesc *theToken,
  167.                                                 long theRefCon);
  168.  
  169. OSErr MakeAppToken(TObjModelToken** theApplicationToken);
  170.  
  171. pascal OSErr AppTokenFromNullAccessor   (DescType desiredClass,
  172.                                                 AEDesc *containerToken,
  173.                                                 DescType containerClass,
  174.                                                 DescType keyForm,
  175.                                                 AEDesc *keyData,
  176.                                                 AEDesc *theToken,
  177.                                                 long theRefCon);
  178.  
  179. pascal OSErr WindowTokenFromNullAccessor(DescType desiredClass,
  180.                                                 AEDesc *containerToken,
  181.                                                 DescType containerClass,
  182.                                                 DescType keyForm,
  183.                                                 AEDesc *keyData,
  184.                                                 AEDesc *theToken,
  185.                                                 long theRefCon);
  186.  
  187. pascal OSErr StdObjectFromNullAccessor  (DescType desiredClass,
  188.                                                 AEDesc *containerToken,
  189.                                                 DescType containerClass,
  190.                                                 DescType keyForm,
  191.                                                 AEDesc *keyData,
  192.                                                 AEDesc *theToken,
  193.                                                 long theRefCon);
  194.  
  195.  
  196. static    pascal OSErr StdObjectAccessor (DescType desiredClass,
  197.                                         AEDesc *containerToken,
  198.                                         DescType containerClass,
  199.                                         DescType keyForm,
  200.                                         AEDesc *keyData,
  201.                                         AEDesc *theToken,
  202.                                         long theRefCon);
  203.                                     
  204. static    pascal OSErr StdPropertyAccessor(DescType desiredClass,
  205.                                         AEDesc *containerToken,
  206.                                         DescType containerClass,
  207.                                         DescType keyForm,
  208.                                         AEDesc *keyData,
  209.                                         AEDesc *theToken,
  210.                                         long theRefCon);
  211.  
  212. // object support callbacks
  213.  
  214. static    pascal OSErr StdCountProc        (DescType desiredClass,
  215.                                         DescType containerClass,
  216.                                         AEDesc *containerToken,
  217.                                         long *result);
  218.                                     
  219. static    pascal OSErr StdCompareProc    (DescType comparisonOperator,
  220.                                         AEDesc object,
  221.                                         DescType objOrDescToCompare,
  222.                                         Boolean& result);
  223.                                             
  224. static    pascal OSErr StdDisposeToken   (AEDesc *unneededToken);
  225.  
  226.  
  227.  
  228. #endif
  229.